# -*- coding = utf-8 -*-
# @Time : 2022/11/30 13:55
# @Author : GHHHHHHHHH
# @File : JudgeTool.py
# @Software : PyCharm
import numpy as np
from sklearn.metrics import accuracy_score
import pandas as pd


def judge(judge_file: pd.DataFrame, ans: pd.DataFrame, fun=accuracy_score):
    assert type(judge_file) == pd.DataFrame and type(ans) == pd.DataFrame, TypeError
    assert judge_file.shape == ans.shape, "Shape of df must be same!"
    judge_file = judge_file.to_numpy()
    ans = ans.to_numpy()
    judge_file = np.array(sorted(judge_file, key=lambda x: x[0]))
    ans = np.array(sorted(ans, key=lambda x: x[0]))
    return fun(judge_file[:, 1], ans[:, 1])
